package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TicketReceiptReal;
import com.ruoyi.system.service.ITicketReceiptRealService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 票据本副联关系Controller
 *
 * @author ruoyi
 * @date 2024-07-19
 */
@RestController
@RequestMapping("/system/real")
public class TicketReceiptRealController extends BaseController
{
    @Autowired
    private ITicketReceiptRealService ticketReceiptRealService;

    /**
     * 查询票据本副联关系列表
     */
    @PreAuthorize("@ss.hasPermi('system:real:list')")
    @GetMapping("/list")
    public TableDataInfo list(TicketReceiptReal ticketReceiptReal)
    {
        startPage();
        List<TicketReceiptReal> list = ticketReceiptRealService.selectTicketReceiptRealList(ticketReceiptReal);
        return getDataTable(list);
    }

    /**
     * 导出票据本副联关系列表
     */
    @PreAuthorize("@ss.hasPermi('system:real:export')")
    @Log(title = "票据本副联关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TicketReceiptReal ticketReceiptReal)
    {
        List<TicketReceiptReal> list = ticketReceiptRealService.selectTicketReceiptRealList(ticketReceiptReal);
        ExcelUtil<TicketReceiptReal> util = new ExcelUtil<TicketReceiptReal>(TicketReceiptReal.class);
        util.exportExcel(response, list, "票据本副联关系数据");
    }

    /**
     * 获取票据本副联关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:real:query')")
    @GetMapping(value = "/{receiptRealNo}")
    public AjaxResult getInfo(@PathVariable("receiptRealNo") String receiptRealNo)
    {
        return success(ticketReceiptRealService.selectTicketReceiptRealByReceiptRealNo(receiptRealNo));
    }

    /**
     * 新增票据本副联关系
     */
    @PreAuthorize("@ss.hasPermi('system:real:add')")
    @Log(title = "票据本副联关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TicketReceiptReal ticketReceiptReal)
    {
        return toAjax(ticketReceiptRealService.insertTicketReceiptReal(ticketReceiptReal));
    }

    /**
     * 修改票据本副联关系
     */
    @PreAuthorize("@ss.hasPermi('system:real:edit')")
    @Log(title = "票据本副联关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TicketReceiptReal ticketReceiptReal)
    {
        return toAjax(ticketReceiptRealService.updateTicketReceiptReal(ticketReceiptReal));
    }

    /**
     * 删除票据本副联关系
     */
    @PreAuthorize("@ss.hasPermi('system:real:remove')")
    @Log(title = "票据本副联关系", businessType = BusinessType.DELETE)
    @DeleteMapping("/{receiptRealNos}")
    public AjaxResult remove(@PathVariable String[] receiptRealNos)
    {
        return toAjax(ticketReceiptRealService.deleteTicketReceiptRealByReceiptRealNos(receiptRealNos));
    }
}
